<template>
  <el-dialog title="踢回公海" :visible.sync="open" append-to-body>
    <el-form :model="form" ref="form" :rules="rules" label-width="80px">
     <el-row>
       <el-col :span="24">
         <el-form-item label="原因" prop="reason">
           <el-select v-model="form.reason" placeholder="请选择原因">
             <el-option v-for="item in dict.type.reasons_for_business_reporting" :label="item.label" :value="item.value "
                        :key="item.value">
             </el-option>
           </el-select>
         </el-form-item>
       </el-col>
     </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="open = false">取 消</el-button>
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
    import { giveBack } from "@/api/crm/businessTrack";

    export default {
      name: "dive-backs",
      dicts:['reasons_for_business_reporting'],
      props:{
          businessId:{type:[String,Number],},
      },//把父组件的值传过来
      data(){
        return{
          open:false,
          form:{},
          rules:{
            reason:[
              {required:true,message:"原因不能为空",trigger:"change"}
            ]
          }
        }
      },
      created(){
        console.log('give-back',this.businessId);
      },
      methods:{
        resetForm(){
          this.form={
            id:null,
            record:null,
          }
        },
        submitForm(){
          this.$refs.form.validate(valid=>{
            if(valid){
              this.form.id=this.businessId
              giveBack(this.form).then(()=>{
                this.$modal.msgSuccess('操作成功');
                this.$emit('success')
              }).catch(()=>this.$modal.msgError('操作失败'))
              this.open=false;
            }
          })
        }
      }

    }
</script>

<style scoped>

</style>
